package com.sample.service.scheduling;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.scheduling.quartz.JobDetailBean;
import org.springframework.scheduling.quartz.SimpleTriggerBean;

import java.text.ParseException;
import java.util.Calendar;

/**
 * Created by IntelliJ IDEA.
 * User: khanhpham
 * Date: 10/26/11
 * Time: 8:48 AM
 * To change this template use File | Settings | File Templates.
 */
public class TestClient {
   public static void main(String[] args) throws ParseException {
      ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
      System.out.println(context);

      SchedulerFactory schedulerFactory = (SchedulerFactory) context.getBean("schedulerFactory");
      JobDetailBean jobDetailBean = JobFactory.createJobDetailBean("myname", SimpleJob.class);
      jobDetailBean.setGroup("mygroup");
      Calendar cal = Calendar.getInstance();

      SimpleTriggerBean simpleTriggerBean = SimpleTriggerFactory.createTrigger(jobDetailBean, cal.getTime(), cal.getTime(), "mygroup", "myname");
      schedulerFactory.scheduleJob(simpleTriggerBean);
      System.out.println();
   }
}
